Results 1 to 2 of 2

Thread: Getting error “duplicate symbol: findNext” when there seems to be no duplication

  1. #1
    Join Date
    Oct 2009
    Posts
    38
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Question Getting error “duplicate symbol: findNext” when there seems to be no duplication

    Hi all,

    I am just starting to use Qt (ok, I looked at it before for a short time, but now I'm back) and I'm trying to compile a simple program, but I'm getting duplicate symbol where there seems to be no duplicates. I'm actually following along in the book "C++ GUI Programming with Qt 4: Second Edition" by Blanchette & Summerfield. Starting on page 13, then talk about creating dialogs, so I created the files they said I should and now I'm getting this error. I have created a new project with the minimum number of lines to still get this error. To do so, I created a new gui application called TestMe, and removed the MainWindow class and header files from the project. I then added a FindDialog class to the project and defined them as such:


    -----------------------------------------main.cpp--------------------------------------------------
    #include <QtGui/QApplication>
    #include "finddialog.h"

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);

    FindDialog *dialog = new FindDialog;
    dialog->show();

    return a.exec();
    }
    -----------------------------------------------------end main.cpp---------------------------------


    --------------------------------------------finddialog.h----------------------------------------
    #ifndef FINDDIALOG_H
    #define FINDDIALOG_H

    #include <QDialog>

    class FindDialog : QDialog
    {
    Q_OBJECT

    public:
    FindDialog(QWidget *parent = 0);

    signals:
    void findNext(const QString &str, Qt::CaseSensitivity cs);

    };

    #endif // FINDDIALOG_H

    --------------------------------------------end finddialog.h----------------------------------------


    --------------------------------------------finddialog.cpp----------------------------------------
    #include "finddialog.h"

    FindDialog::FindDialog(QWidget *parent)
    : QDialog(parent)
    {
    }

    void FindDialog::findNext(const QString &str, Qt::CaseSensitivity cs)
    {
    }

    --------------------------------------------end finddialog.cpp----------------------------------------


    The error I'm getting from a fresh creation of this small project is:


    --------------------------------------------compiler output----------------------------------------
    Running build steps for project TestMe...
    Configuration unchanged, skipping qmake step.
    Starting: "/usr/bin/make" -w
    make: Entering directory `/Users/bruce/Projects/Qt Projects/TestMe-build-desktop'
    g++ -c -pipe -g -gdwarf-2 -arch i386 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Qt4.6/mkspecs/macx-g++ -I../TestMe -I/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore -I/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/QtGui -I/usr/include -I. -I../TestMe -I. -F/Library/Frameworks -o finddialog.o ../TestMe/finddialog.cpp
    ../TestMe/finddialog.cpp:8: warning: unused parameter 'str'
    ../TestMe/finddialog.cpp:8: warning: unused parameter 'cs'
    /Developer/Tools/Qt/moc -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Qt4.6/mkspecs/macx-g++ -I../TestMe -I/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore -I/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/QtGui -I/usr/include -I. -I../TestMe -I. -F/Library/Frameworks -D__APPLE__ -D__GNUC__ ../TestMe/finddialog.h -o moc_finddialog.cpp
    g++ -c -pipe -g -gdwarf-2 -arch i386 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Qt4.6/mkspecs/macx-g++ -I../TestMe -I/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore -I/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/QtGui -I/usr/include -I. -I../TestMe -I. -F/Library/Frameworks -o moc_finddialog.o moc_finddialog.cpp
    g++ -headerpad_max_install_names -arch i386 -o TestMe.app/Contents/MacOS/TestMe main.o finddialog.o moc_finddialog.o -F/Library/Frameworks -L/Library/Frameworks -framework QtGui -framework QtCore
    ld: duplicate symbol FindDialog::findNext(QString const&, Qt::CaseSensitivity) in moc_finddialog.o and finddialog.o
    collect2: ld returned 1 exit status
    make: *** [TestMe.app/Contents/MacOS/TestMe] Error 1
    make: Leaving directory `/Users/bruce/Projects/Qt Projects/TestMe-build-desktop'
    The process "/usr/bin/make" exited with code %2.
    Error while building project TestMe (target: Desktop)
    When executing build step 'Make'
    --------------------------------------------end compiler output-----------------------------------

    I have tried to figure this out, but don't seem to understand enough of what is going on with the moc process. If I comment out both the declaration and definition of the findNext() method, the compilation runs perfectly well. Can anybody help me with this? Seems like such a simple thing.

    Thanks...

  2. #2
    Join Date
    May 2010
    Posts
    24
    Thanked 8 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Getting error “duplicate symbol: findNext” when there seems to be no duplication

    Signals are automatically implemented by the moc, you should not implement them yourself.

    Just to be clear, you have to remove these lines from your .cpp.
    Qt Code:
    1. void FindDialog::findNext(const QString &str, Qt::CaseSensitivity cs)
    2. {
    3. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 1
    Last Post: 22nd June 2010, 19:56
  2. symbol lookup error
    By knishaq in forum Qt Programming
    Replies: 1
    Last Post: 22nd June 2010, 15:22
  3. Dynamic load QT Plugin - symbol lookup error
    By qlands in forum Qt Programming
    Replies: 4
    Last Post: 2nd May 2010, 19:37
  4. QT-Embedded Symbol Lookup Error
    By augusbas in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 23rd June 2009, 05:01
  5. symbol lookup error when using plugins
    By macbeth in forum Qt Programming
    Replies: 3
    Last Post: 29th July 2006, 09:54

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.